home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CNVLIB.ZIP / INCLIST.CMM < prev    next >
Encoding:
Text File  |  1994-03-22  |  1.4 KB  |  58 lines

  1. // IncList.cmm - CEnvi file to list all of the #include files
  2. // ver.1         for C-type files in a source file.
  3.  
  4. main(argc,argv)
  5. {
  6.    if ( argc != 2 )
  7.       Instructions();
  8.    else if ( !(fp = fopen(argv[1],"rt")) )
  9.       Instructions();
  10.    else {
  11.       printf("%s : \n",argv[1]);
  12.       ListIncludeFiles(fp);
  13.       printf("\n");
  14.       fclose(fp);
  15.    }
  16. }
  17.  
  18. Instructions()
  19. {
  20.    printf("\a\n");
  21.    printf("IncList: List #include files from C-type soure files\n");
  22.    printf("\n");
  23.    printf("USAGE: CEnvi IncList <FileSpec>\n");
  24.    printf("\n");
  25.    printf("WHERE: FileSpec - specification for source file\n");
  26.    printf("\n");
  27. }
  28.  
  29. ListIncludeFiles(fp)
  30. {
  31.    IncludeKey = "#include";
  32.    IncludeKeyLen = strlen(IncludeKey);
  33.  
  34.    while ( line = fgets(fp) ) {
  35.  
  36.       // find a #, which may indicate #include
  37.       if ( line = strchr(line,'#') ) {
  38.  
  39.          if ( !strnicmp(line,IncludeKey,IncludeKeyLen) ) {
  40.  
  41.             line += IncludeKeyLen;
  42.             // skip to next char after whitespace
  43.             while ( strchr(" \t",line[0]) )
  44.                line++;
  45.  
  46.             // read between this quote char and next one
  47.             QuoteChar = line[0];
  48.             if ( QuoteChar != '<'  &&  (LineEnd = strchr(++line,QuoteChar)) ) {
  49.                LineEnd[0] = 0;
  50.                printf(" %s\n",line);
  51.             }
  52.          }
  53.       }
  54.    }
  55. }
  56.  
  57.  
  58.